package com.netease.nim.uikit.team.helper;

import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.msg.MessageBuilder;
import com.netease.nimlib.sdk.msg.MsgService;
import com.netease.nimlib.sdk.msg.constant.MsgStatusEnum;
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
import com.netease.nimlib.sdk.msg.model.CustomMessageConfig;
import com.netease.nimlib.sdk.msg.model.IMMessage;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by nick on 2017/9/27.
 */

public class TipMessageHelper {

    public static final void insertTipMessage(String teamId,String message){
        Map<String, Object> content = new HashMap<>(1);
        content.put("content", message);
       // 创建tip消息，teamId需要开发者已经存在的team的teamId
        IMMessage msg = MessageBuilder.createTipMessage(teamId, SessionTypeEnum.Team);
        msg.setRemoteExtension(content);
        msg.setContent(message);
       // 自定义消息配置选项
        CustomMessageConfig config = new CustomMessageConfig();
       // 消息不计入未读
        config.enableUnreadCount = false;
        msg.setConfig(config);
       // 消息发送状态设置为success
        msg.setStatus(MsgStatusEnum.success);
       // 保存消息到本地数据库，但不发送到服务器
        NIMClient.getService(MsgService.class).saveMessageToLocal(msg, true);
    }
}
